<?php

namespace app\db\controller;

use app\common\controller\Database;
use app\common\library\Upload;
use app\common\exception\UploadException;

class Common extends Database
{
	protected $noNeedLogin = [];
    protected $noNeedRight = ['upload'];
    protected $layout = '';

    public function _initialize()
    {
        parent::_initialize();
        //设置过滤方法
        $this->request->filter(['trim']);
    }
    /**
     * 上传文件
     * @author MSQ 2021-9-3
    **/
	public function upload()
	{
		$data = [];
        $file = $this->request->file('file');
        try {
            $upload = new Upload($file);
            $data = $upload->upload('',false);
        } catch (UploadException $e) {
            $this->error($e->getMessage());
        }
        $this->success('上传成功',$data);
	}
}
